cereal writes: http (Hypertext transfer Protocol) is the protocol that allows Web servers and browsers to exchange data over the web. It is a request/response protocol, meaning the server waits for and responds to client requests. HTTP does not
maintain a connection whit the client. HTTP predominantly uses reliable TCP connections, most often on port 80.
These client/server transactions can be divided into four basic steps:
1, the browser connects to the server
2, the browser requests a document from the server
3, the server responds to the browser
4, the connection is dropped
Http is a stateless protocol in that it dos not maintain any information about the connection.
1. HTTP 1.1,
To make communication possible between the server and the client, the HTTP-protocol establishes a language of the web that is made up of request and response messages.
1.1 Client Request,
A client request contains the following information:
1, Request Method
2, Request Header
3, Request Data
The Request Method is the program to be applied to the specified URL or Web page.
Below are the available methods shown.
Method Description
GET Requests the specified document
HEAD Requests only the document head
POST Request that the server accept the specified document as an executable and pass it some information
PUT Replace the contents of the specified document with data from the client.
DELETE Request that the server delete the specified page
OPTIONS Allows the client to see the capabilities or requirements of the server
TRACE Used for testing, allows the client to se how the message was retrieved
The Header information is optional, and is used to provide the server whit additional information about the client.
Below are the available headers shown.
Header Description
Accept The type of data the client will accept
Authorization Includes authentication information like username and password
User-Agent The type of client software being used
Referer The web page from which the user is coming. (and yes it is spelled this way)
If the method used requires data from the client (example: POST) the client follows the header with data. Otherwise the client waits for a response from the server.
1.2 Server Response,
Server response also contains several key items:
1, Status code
2, Response Header
3, Response Data
HTTP defines several groups of status codes to communicate back to the browser
Code What example
1xx Information 100 = Continue
2xx Successful 202 = Accepted
3xx Redirection 305 = Use Proxy
4xx Client Error 404 = Not found 403 = Forbidden
5xx Server Error 500 = Internal Server Error
Response headers provide the client with information about the server and/or requested document.
Method Description
Server Information about the Web server
Date The current date/time
Last modified The date/time that the requested document was last modified
Expires The date/time that the requested document expires.
Content-type The MIME Type of data
Content-length The size (in bytes) of data
WWW-authenticate Used to tell the client the information that is required for authentication
If the client has requested data, the data will follow. Otherwise the server closes the connection.
2. MIME and the web,
Multipurpose Internet Mail Extension (MIME) are used on the Web to specify the classification of a chunk of data (example : a file of a web page). Mime allows you to send data in formats other than plain text. Thanks to MIME, you can send and receive
Web pages that contain non-ASCII data such as sound, video, à
When Web browsers and servers communicate, they discuss MIME types. The browser can send information about the MIME types it can accept in the request header. The server tells the client the MIME type of data it is about to send.
Mime Type Description
text/plain Plain ASCII text
text/html HTML text
image/gif GIFF image
image/jpeg JPEG image
application/msword Microsoft Word
video/mpeg MPEG video
audio/wave Wave audio
application/x-tar Tar compressed data
3. Sample HTTP Communication,
3.1 The request,
In this example, the browser is requesting the document identified by the URL http://www.example.com/index.html. All request end whit a blank line, as shown here:
GET /index.html HTTP/1.1
Accept: text/plain
Accept: text/html
User-agent: Mozilla/4.5 (winNT)
(blank line)
The browser is using the GET method to request the document /index.html. The browser indicates that it will only accept plain text and HTML data, and that it is using the Mozilla/4.5 engine.
3.2 The Response,
The server responds whit a status code, some header information (followed by a blank line), and if applicable, the requested data.
HTTP/1.1 200 OK
Date Sunday, 25-jul-02 12:18:03 GMT
Server: Apache/1.3.6
MIME-version: 1.0
Content-type: text/html
Last-modified: thursday, 20-jun-02 20:43:56 GMT
Content-length: 1423
(blank line)
(and then the HTML code)
The next example assumes the document was not found:
HTTP/1.1 404 NOT FOUND
Date Sunday, 25-jul-02 12:18:03 GMT
Server: Apache/1.3.6
well thats it, i think, would not know what to write more about it.